﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Jxym.DBUtility;
using Jxym.wlkc2011.Module.CMS.MODEL;

namespace Jxym.wlkc2011.WebSite
{
    public partial class zjgx : System.Web.UI.UserControl
    {
        #region ZS

        private int _l = 0;

        private string _title = "未命名";

        private int _topN = 0;

        public string MyTitle
        {
            get { return _title; }
            set { _title = value; }
        }

        public int TopN
        {
            get { return _topN; }
            set { _topN = value; }
        }

        public int L
        {
            get { return _l; }
            set { _l = value; }
        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Params["siteName"] != null)
                {
                    _siteName = Request.Params["siteName"];

                    MsSqlDal<Cms_ContentClass> ccc = new MsSqlDal<Cms_ContentClass>();

                    Cms_ContentClass cccInfo = ccc.GetModel("Title='" + _title + "'", null);

                    if (cccInfo != null)
                    {
                        MsSqlDal<Cms_Content> cct = new MsSqlDal<Cms_Content>();

                        IList<Cms_Content> list = cct.GetList("ContentClassID=" + cccInfo.ID, null, "", _topN);

                        if (list.Count > 1)
                        {
                            Repeater1.Visible = true;
                            Panel1.Visible = false;
                            Repeater1.DataSource = list;
                            Repeater1.DataBind();
                        }
                        else if (list.Count == 1)
                        {
                            Repeater1.Visible = false;

                            Panel1.Visible = true;

                            string xxly = "";

                            if (_l > 0)
                            {
                                xxly = "<strong class=\"zjr\">" + list[0].FromW + "</strong>";

                                Literal1.Text = xxly + "<a class=\"p\" href=\"" + _siteName + "_m" + list[0].ContentClassID + ".htm\">" + Jxym.Tools.Char.MySubstring(Jxym.Tools.Char.DelHTML(list[0].Html), _l) + "</a>";
                            }
                            else
                            {
                                Literal1.Text = xxly + "<a class=\"p\" href=\"" + _siteName + "_m" + list[0].ContentClassID + ".htm\">" + Jxym.Tools.Char.DelHTML(list[0].Html) + "</a>";
                            }

                            if (list[0].ViewPhoto != "no.jpg" && list[0].ViewPhoto != "")
                            {
                                Literal2.Text = "<img src=\"" + "UpFiles/" + _siteName + "/" + list[0].ViewPhoto + "\" style=\"height:164px; width:121px; border:0px;float: left; margin: 0px 10px 10px 0px;\" class=\"img_bg\"/>";
                            }
                        }
                        else
                        {
                            Repeater1.Visible = false;
                            Panel1.Visible = true;
                            Literal1.Text = "暂无信息";
                        }
                    }
                }
            }
        }

        public string _siteName { get; set; }
    }
}